# $Id$
# Maintainer : Guillaume ALAUX <guillaume@archlinux.org>
# Contributor: Jochem Kossen   <j.kossen@home.nl>
# Contributor: rtfreedman      <rob.til.freedman@googlemail.com>

pkgname=id3lib
pkgver=3.8.3
pkgrel=16
pkgdesc='Library for reading, writing, and manipulating ID3v1 and ID3v2 tags'
arch=('i686' 'x86_64')
license=('LGPL')
url="http://id3lib.sourceforge.net/"
depends=('zlib' 'gcc-libs')
source=(http://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.gz
        00-add-libz-to-compilation.patch
        05-create-m4-directory.patch
        10-fix-compilation-with-cpp-headers.patch
        15-fix-headers-of-main-functions.patch
        20-create-manpages.patch
        30-fix-utf16.patch
        40-deal-with-mkstemp.patch
        50-remove-outdated-check.patch
        60-add-c-wrapper-functions.patch
        60-fix_make_check.patch
        60-id3lib-missing-nullpointer-check.patch
        60-spelling.patch
        61-fix_vbr_stack_smash.patch)

md5sums=('19f27ddd2dda4b2d26a559a4f0f402a7'
         '9428ef38283d13adb6e349089537a63f'
         '5a78e0fe586fba334eae2a29e4bf5a28'
         '88f21f1bf4f697be8030706bbec11705'
         'b3de841cd2eda0d37c8c8330119e12d4'
         '0c7c939943bdfcc3a0f6be95fe9b2367'
         '74ba59c03f91fedbe4dd8045b29c7e15'
         'd2d06d46df3867d73746f584d1e6fcc5'
         'd3a61d07a2bfa83f4ac6290794789022'
         '93ef4b26ad08027e28d3f80ad6e492b4'
         '5c4b53a3d5543c5c50b23d6d5b9f230b'
         '964fa0db0da7b1495b34b81bd36539fd'
         '26c74a90267892bbaca1e162919121d0'
         '0973e285cdc420130b984a259cdd8ae0')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  patch -p1 -i ../00-add-libz-to-compilation.patch
  patch -p1 -i ../05-create-m4-directory.patch
  patch -p1 -i ../10-fix-compilation-with-cpp-headers.patch
  patch -p1 -i ../15-fix-headers-of-main-functions.patch
  patch -p1 -i ../20-create-manpages.patch
  patch -p1 -i ../30-fix-utf16.patch
  patch -p1 -i ../40-deal-with-mkstemp.patch
  patch -p1 -i ../60-add-c-wrapper-functions.patch
  patch -p1 -i ../60-fix_make_check.patch
  patch -p1 -i ../60-id3lib-missing-nullpointer-check.patch
  patch -p1 -i ../60-spelling.patch
  patch -p1 -i ../61-fix_vbr_stack_smash.patch
  patch -p1 -i ../50-remove-outdated-check.patch

  libtoolize -fc
  aclocal
  autoconf
  automake --add-missing --copy
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr
  make
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  install -d "${pkgdir}"/usr/share/man/man1
  cp doc/man/* "${pkgdir}"/usr/share/man/man1
}
